package com.cn.common;

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

public class BrokerData {

    private String cluster;

    private String brokerName;

    private TreeMap<Integer, String> addr = new TreeMap<>();

    public BrokerData() {
    }

    public BrokerData(String cluster, String brokerName, TreeMap<Integer, String> addr) {
        this.cluster = cluster;
        this.brokerName = brokerName;
        this.addr = addr;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        BrokerData old = (BrokerData) obj;
        if (cluster == null) {
            if (old.getCluster() != null) {
                return false;
            }
        } else if (!cluster.equals(old.getCluster())) {
            return false;
        }

        if (brokerName == null) {
            if (old.getBrokerName() != null) {
                return false;
            }
        } else if (!brokerName.equals(old.getBrokerName())) {
            return false;
        }

        if (addr == null) {
            if (old.getAddr() != null) {
                return false;
            }
        } else if (!addr.equals(old.getAddr())) {
            return false;
        }

        return true;
    }

    public String getCluster() {
        return cluster;
    }

    public void setCluster(String cluster) {
        this.cluster = cluster;
    }

    public String getBrokerName() {
        return brokerName;
    }

    public void setBrokerName(String brokerName) {
        this.brokerName = brokerName;
    }

    public TreeMap<Integer, String> getAddr() {
        return addr;
    }

    public void setAddr(TreeMap<Integer, String> addr) {
        this.addr = addr;
    }

    public static void main(String[] args) {
        TreeMap<Integer, String> map1 = new TreeMap<>();
        map1.put(0, "a");
        map1.put(1, "b");


        TreeMap<Integer, String> map2 = new TreeMap<>();
        map2.put(0, "a");
        map2.put(1, "b");

        System.out.println(map1.equals(map2));
    }

}
